import service from '@/utils/request'

interface ApiFace {
  [key: string]: string
}

interface requestParamsFace {
  url: string
  method?: string
  params?: any
  data?: any
}

const apis: ApiFace = {
  imageCode: '/app/imageCode',
  login: '/app/login',
  info: '/app/info',
  menusTree: '/app/menus',
  userList: '/user/list',
  sentenceList: '/resource/sentences',
  idiomList: '/resource/idioms',
  constellationList: '/resource/constellations',
  constellationMateList: '/resource/constellationMates',
  flowerLangs: '/resource/flowerLangs',
  sentenceError: '/resource/errors',
  coupletList: '/resource/couplets',
  contentCategories: '/content/categories',
  contentArticles: '/content/articles'
}

export default function request(req: requestParamsFace) {
  return service({
    url: apis[req.url],
    method: req.method || 'get',
    params: req.params,
    data: req.data
  })
}
